<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Lz.php';


class LzArr
{
    static public
    function first($arr)
    {
        return reset($arr);
    }


    static public
    function last($arr)
    {
        return end($arr);
    }


    static public
    function like($var)
    {
        return is_array($var) || ($var instanceof Traversable);
    }


    static public
    function pure($arr)
    {
        if (is_array($arr))
            return $arr;
        if (Lz::eachable($arr))
            return iterator_to_array($arr);
        return array($arr);
    }


    static public
    function urlencode($arr)
    {
        foreach ($arr as $k => $val)
        {
            if (Lz::eachable($val))
                $arr[$k]    = self::urlencode($val);
            else
                $arr[$k]    = urlencode($val);
        }
        return $arr;
    }


    private
    function __construct()
    {}
}

